inherited fmRS_tabel_indiv: TfmRS_tabel_indiv
  Left = 528
  Top = 91
  Width = 476
  Height = 806
  Caption = #1058#1072#1073#1077#1083#1100' '#1080#1085#1076#1080#1074#1080#1076#1091#1072#1083#1100#1085#1099#1081
  Constraints.MinHeight = 806
  Constraints.MinWidth = 476
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 748
    Width = 468
    Height = 24
  end
  inherited Panel1: TPanel
    Width = 468
    inherited BitBtn1: TBitBtn
      Left = 298
      Kind = bkCustom
    end
    inherited BitBtn2: TBitBtn
      Left = 386
      Kind = bkCustom
    end
  end
  object pcTabel: TcxPageControl [2]
    Left = 0
    Top = 45
    Width = 468
    Height = 703
    ActivePage = tsTabel
    Align = alClient
    TabOrder = 2
    ClientRectBottom = 702
    ClientRectLeft = 1
    ClientRectRight = 467
    ClientRectTop = 21
    object tsTabel: TcxTabSheet
      Caption = #1058#1072#1073#1077#1083#1100
      ImageIndex = 0
      object Panel2: TPanel
        Left = 0
        Top = 0
        Width = 466
        Height = 561
        Align = alTop
        TabOrder = 0
        object Label7: TLabel
          Left = 8
          Top = 12
          Width = 134
          Height = 13
          Caption = #1044#1072#1090#1072' '#1087#1088#1086#1074#1077#1076#1077#1085#1080#1103' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label1: TLabel
          Left = 8
          Top = 68
          Width = 113
          Height = 13
          Caption = #1042#1088#1077#1084#1103' '#1085#1072#1095#1072#1083#1072' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label2: TLabel
          Left = 152
          Top = 68
          Width = 131
          Height = 13
          Caption = #1042#1088#1077#1084#1103' '#1086#1082#1086#1085#1095#1072#1085#1080#1103' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label3: TLabel
          Left = 160
          Top = 12
          Width = 35
          Height = 13
          Caption = #1059#1089#1083#1091#1075#1072
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label4: TLabel
          Left = 8
          Top = 124
          Width = 68
          Height = 13
          Caption = #1058#1077#1084#1072' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label5: TLabel
          Left = 8
          Top = 236
          Width = 65
          Height = 13
          Caption = #1042#1086#1089#1087#1080#1090#1072#1085#1085#1080#1082
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label9: TLabel
          Left = 8
          Top = 324
          Width = 65
          Height = 13
          Caption = #1053#1072#1073#1083#1102#1076#1077#1085#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label10: TLabel
          Left = 8
          Top = 444
          Width = 43
          Height = 13
          Caption = #1047#1072#1076#1072#1085#1080#1077
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label11: TLabel
          Left = 12
          Top = 288
          Width = 38
          Height = 13
          Caption = #1054#1094#1077#1085#1082#1072
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object eRSDATE: TcxDBDateEdit
          Left = 8
          Top = 30
          DataBinding.DataField = 'RSDATE'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DateButtons = [btnClear, btnToday]
          Properties.InputKind = ikMask
          Properties.SaveTime = False
          Properties.ShowTime = False
          Properties.WeekNumbers = True
          Properties.OnChange = eRSDATEPropertiesChange
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 0
          Width = 137
        end
        object eRSTIMEBEGIN: TcxDBTimeEdit
          Left = 8
          Top = 88
          DataBinding.DataField = 'RSTIMEBEGIN'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.TimeFormat = tfHourMin
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 2
          Width = 121
        end
        object eRSTIMEEND: TcxDBTimeEdit
          Left = 152
          Top = 88
          DataBinding.DataField = 'RSTIMEEND'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.TimeFormat = tfHourMin
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 3
          Width = 121
        end
        object ltvUsluga: TdxDBLookupTreeView
          Left = 156
          Top = 30
          Width = 297
          Height = 24
          CanSelectParents = False
          DropDownRows = 25
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -13
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentColor = False
          ParentFont = False
          TabOrder = 1
          TabStop = True
          Text = 'ltvUsluga'
          TreeViewColor = clWindow
          TreeViewCursor = crDefault
          TreeViewFont.Charset = DEFAULT_CHARSET
          TreeViewFont.Color = clWindowText
          TreeViewFont.Height = -11
          TreeViewFont.Name = 'MS Sans Serif'
          TreeViewFont.Style = []
          TreeViewIndent = 19
          TreeViewReadOnly = False
          TreeViewShowButtons = True
          TreeViewShowHint = False
          TreeViewShowLines = True
          TreeViewShowRoot = True
          TreeViewSortType = stNone
          TreeViewStateImages = DMInv.ilBJTree
          DisplayField = 'SDNAME'
          DividedChar = '.'
          ImageIndexField = 'SDISDELETE'
          ListSource = dsSD
          KeyField = 'SDID'
          ListField = 'SDNAME'
          Options = [trDBCanDelete, trDBConfirmDelete, trCanDBNavigate, trSmartRecordCopy, trCheckHasChildren]
          ParentField = 'SDPARID'
          RootValue = 0
          TextStyle = tvtsShort
          DataField = 'SDID'
          DataSource = dlgDS
        end
        object cxDBMemo1: TcxDBMemo
          Left = 8
          Top = 144
          DataBinding.DataField = 'RSTEMA'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 4
          Height = 89
          Width = 441
        end
        object lcbPU: TcxDBLookupComboBox
          Left = 8
          Top = 254
          DataBinding.DataField = 'PID'
          DataBinding.DataSource = dsVosp
          ParentFont = False
          Properties.DropDownListStyle = lsEditList
          Properties.DropDownRows = 15
          Properties.KeyFieldNames = 'PID'
          Properties.ListColumns = <
            item
              Caption = #1060#1048#1054
              FieldName = 'PP'
            end
            item
              Caption = #1044#1072#1090#1072' '#1088#1086#1078#1076'.'
              Fixed = True
              FieldName = 'PDATEBIRTH'
            end
            item
              Caption = #1054#1073#1088#1072#1079'. '#1087#1086#1076#1088#1072#1079#1076'.'
              FieldName = 'PODR'
            end>
          Properties.ListSource = dsPoluchUslug
          Properties.MaxLength = 0
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clBlack
          Style.Font.Height = -15
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.Shadow = True
          Style.IsFontAssigned = True
          TabOrder = 5
          OnClick = lcbPUClick
          Width = 441
        end
        object cxDBMemo2: TcxDBMemo
          Left = 8
          Top = 344
          DataBinding.DataField = 'RSNABLJUD'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 6
          Height = 89
          Width = 441
        end
        object cxDBMemo3: TcxDBMemo
          Left = 8
          Top = 464
          DataBinding.DataField = 'RSZADANIE'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 7
          Height = 89
          Width = 441
        end
        object cxDBComboBox1: TcxDBComboBox
          Left = 56
          Top = 288
          DataBinding.DataField = 'RSPLEVEL'
          DataBinding.DataSource = dsVosp
          ParentFont = False
          Properties.DropDownListStyle = lsEditFixedList
          Properties.Items.Strings = (
            '1'
            '2'
            '3'
            '4'
            '5')
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.IsFontAssigned = True
          TabOrder = 8
          Width = 49
        end
      end
      object Panel3: TPanel
        Left = 0
        Top = 566
        Width = 466
        Height = 115
        Align = alBottom
        TabOrder = 1
        object Label6: TLabel
          Left = 16
          Top = 7
          Width = 99
          Height = 13
          Caption = #1047#1072#1085#1103#1090#1080#1077' '#1087#1088#1086#1074#1077#1083'(-'#1072')'
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label8: TLabel
          Left = 16
          Top = 58
          Width = 150
          Height = 13
          Caption = #1040#1076#1084#1080#1085#1080#1089#1090#1088#1072#1090#1080#1074#1085#1099#1081' '#1088#1072#1073#1086#1090#1085#1080#1082
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object lcbPedag: TcxDBLookupComboBox
          Left = 14
          Top = 22
          DataBinding.DataField = 'PID_PEDAG'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DropDownListStyle = lsEditList
          Properties.DropDownRows = 15
          Properties.KeyFieldNames = 'PID'
          Properties.ListColumns = <
            item
              Caption = #1060#1048#1054
              FieldName = 'PP'
            end
            item
              Caption = #1057#1090#1072#1090#1091#1089
              FieldName = 'SDNAME'
            end>
          Properties.ListSource = dsSotr
          Properties.MaxLength = 0
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clBlack
          Style.Font.Height = -15
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.Shadow = False
          Style.IsFontAssigned = True
          TabOrder = 0
          Width = 443
        end
        object lcbAdm: TcxDBLookupComboBox
          Left = 14
          Top = 73
          DataBinding.DataField = 'PID_ADM'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DropDownListStyle = lsEditList
          Properties.DropDownRows = 15
          Properties.KeyFieldNames = 'PID'
          Properties.ListColumns = <
            item
              Caption = #1060#1048#1054
              FieldName = 'PP'
            end
            item
              Caption = #1057#1090#1072#1090#1091#1089
              FieldName = 'SDNAME'
            end>
          Properties.ListSource = dsSotr2
          Properties.MaxLength = 0
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clBlack
          Style.Font.Height = -15
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.Shadow = False
          Style.IsFontAssigned = True
          TabOrder = 1
          Width = 443
        end
      end
    end
  end
  inherited dlgDS: TDataSource
    OnDataChange = dlgDSDataChange
  end
  object dsSD: TDataSource
    DataSet = qSD
    Left = 203
    Top = 174
  end
  object qSD: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 20'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      '')
    GeneratorField.Field = 'SDID'
    Left = 232
    Top = 176
    object qSDSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qSDSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qSDSDNAME: TIBStringField
      DisplayLabel = #1069#1083#1077#1084#1077#1085#1090
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 2304
    end
    object qSDSDISDELETE: TIntegerField
      DisplayLabel = #1059#1076#1072#1083#1080#1090#1100'?'
      FieldName = 'SDISDELETE'
      Origin = '"SYS_DIC"."SDISDELETE"'
    end
  end
  object qVosp: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    AfterInsert = qVospAfterInsert
    CachedUpdates = True
    DataSource = dlgDS
    SQL.Strings = (
      'SELECT RSP.*, sd.SDNAME AS osn_podr'
      'FROM RS_PEOPLE RSP'
      
        'LEFT OUTER JOIN deti_podrazd dp ON dp.pid = rsp.PID AND current_' +
        'date BETWEEN CAST(dp.dpdatein AS DATE) AND COALESCE(CAST(dp.dpda' +
        'teout AS DATE), current_date + 3650)'
      'LEFT OUTER JOIN sys_dic sd ON sd.sdid = dp.sdid'
      'WHERE RSP.RSID = :RSID'
      'AND RSP.RSPISDELETE IS NULL')
    UpdateObject = quVosp
    Left = 168
    Top = 392
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'RSID'
        ParamType = ptUnknown
      end>
    object qVospRSID: TIntegerField
      FieldName = 'RSID'
      Origin = '"RS_PEOPLE"."RSID"'
      Required = True
    end
    object qVospPID: TIntegerField
      FieldName = 'PID'
      Origin = '"RS_PEOPLE"."PID"'
    end
    object qVospRSPLEVEL: TIntegerField
      FieldName = 'RSPLEVEL'
      Origin = '"RS_PEOPLE"."RSPLEVEL"'
    end
    object qVospRSPUSERENTER: TIBStringField
      FieldName = 'RSPUSERENTER'
      Origin = '"RS_PEOPLE"."RSPUSERENTER"'
      Size = 40
    end
    object qVospRSPTIMEENTER: TDateTimeField
      FieldName = 'RSPTIMEENTER'
      Origin = '"RS_PEOPLE"."RSPTIMEENTER"'
    end
    object qVospRSPUSEREDIT: TIBStringField
      FieldName = 'RSPUSEREDIT'
      Origin = '"RS_PEOPLE"."RSPUSEREDIT"'
      Size = 40
    end
    object qVospRSPTIMEEDIT: TDateTimeField
      FieldName = 'RSPTIMEEDIT'
      Origin = '"RS_PEOPLE"."RSPTIMEEDIT"'
    end
    object qVospRSPNOTE: TIBStringField
      FieldName = 'RSPNOTE'
      Origin = '"RS_PEOPLE"."RSPNOTE"'
      Size = 255
    end
    object qVospOSN_PODR: TIBStringField
      FieldName = 'OSN_PODR'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
  end
  object quVosp: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  RSID,'
      '  PID,'
      '  RSPLEVEL,'
      '  RSPUSERENTER,'
      '  RSPTIMEENTER,'
      '  RSPUSEREDIT,'
      '  RSPTIMEEDIT,'
      '  RSPNOTE,'
      '  RSPISDELETE,'
      '  OSN_PODR'
      'from RS_PEOPLE '
      'where'
      '  PID = :PID and'
      '  RSID = :RSID')
    ModifySQL.Strings = (
      'update RS_PEOPLE'
      'set'
      '  PID = :PID,'
      '  RSID = :RSID,'
      '  RSPISDELETE = :RSPISDELETE,'
      '  RSPLEVEL = :RSPLEVEL,'
      '  RSPNOTE = :RSPNOTE'
      'where'
      '  PID = :OLD_PID and'
      '  RSID = :OLD_RSID')
    InsertSQL.Strings = (
      'insert into RS_PEOPLE'
      '  (PID, RSID, RSPISDELETE, RSPLEVEL, RSPNOTE)'
      'values'
      '  (:PID, :RSID, :RSPISDELETE, :RSPLEVEL, :RSPNOTE)')
    DeleteSQL.Strings = (
      'update RS_PEOPLE'
      'set'
      '  RSPISDELETE = 1'
      'where'
      '  PID = :OLD_PID and'
      '  RSID = :OLD_RSID'
      '')
    Left = 200
    Top = 392
  end
  object dsVosp: TDataSource
    DataSet = qVosp
    Left = 136
    Top = 392
  end
  object dsPoluchUslug: TDataSource
    DataSet = qPoluchUslug
    Left = 168
    Top = 437
  end
  object qPoluchUslug: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    BeforeOpen = qPoluchUslugBeforeOpen
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND CURRENT_DA' +
        'TE BETWEEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATE' +
        'OUT AS DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT RSP.PID, COUNT (RSP.PID) AS proveli'
      'FROM RENDERING_SERVICES RS'
      'INNER JOIN RS_PEOPLE RSP ON RSP.RSID = RS.RSID'
      'WHERE RS.SDID = :SDID'
      '    AND RS.RSISDELETE IS NULL'
      '    AND RSP.RSPISDELETE IS NULL'
      'GROUP BY 1'
      ') AS okaz_uslugi ON okaz_uslugi.PID = P.PID'
      'LEFT OUTER JOIN ('
      '    SELECT APU.PID, SUM(S.SCOUNT) AS zakazali'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :SDID'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 0'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      
        '    AND  (zakaz_uslugi.zakazali - COALESCE(okaz_uslugi.proveli, ' +
        '0)) > 0'
      'UNION'
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND CURRENT_DA' +
        'TE BETWEEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATE' +
        'OUT AS DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN ('
      '    SELECT APU.PID'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :SDID'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 2'
      '    AND :data BETWEEN SC.SCDATEBEGIN AND SC.SCDATEEND'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      'ORDER BY 2'
      '')
    Left = 200
    Top = 437
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end>
    object qPoluchUslugPID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qPoluchUslugPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qPoluchUslugSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qPoluchUslugPODR: TIBStringField
      FieldName = 'PODR'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qPoluchUslugPDATEBIRTH: TDateField
      FieldName = 'PDATEBIRTH'
      Origin = '"PEOPLE"."PDATEBIRTH"'
    end
  end
  object qSotr: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, PS.SDID'
      'FROM PEOPLE P'
      'INNER JOIN P_STATUS PS ON PS.PID = P.PID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN'
      '('
      'SELECT t1.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 1470'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'WHERE t1.sdid <> 1783'
      ') as sotr on sotr.sdid = ps.SDID'
      'WHERE P.PISDELETE IS NULL'
      'UNION'
      'SELECT FIRST 1 NULL AS PID, NULL AS PP,'
      '    NULL AS SDNAME, NULL AS SDID'
      'FROM PEOPLE P'
      'ORDER BY 2')
    Left = 248
    Top = 600
    object qSotrPID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
    end
    object qSotrPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qSotrSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qSotrSDID: TIntegerField
      FieldName = 'SDID'
      Origin = '"P_STATUS"."SDID"'
    end
  end
  object dsSotr: TDataSource
    DataSet = qSotr
    Left = 216
    Top = 600
  end
  object qSotr2: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, PS.SDID'
      'FROM PEOPLE P'
      'INNER JOIN P_STATUS PS ON PS.PID = P.PID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN'
      '('
      'SELECT t1.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 1470'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'WHERE t1.sdid <> 1783'
      ') as sotr on sotr.sdid = ps.SDID'
      'WHERE P.PISDELETE IS NULL'
      'UNION'
      'SELECT FIRST 1 NULL AS PID, NULL AS PP,'
      '    NULL AS SDNAME, NULL AS SDID'
      'FROM PEOPLE P'
      'ORDER BY 2')
    Left = 248
    Top = 632
    object IntegerField1: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
    end
    object IBStringField1: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object IBStringField2: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object IntegerField2: TIntegerField
      FieldName = 'SDID'
      Origin = '"P_STATUS"."SDID"'
    end
  end
  object dsSotr2: TDataSource
    DataSet = qSotr2
    Left = 216
    Top = 632
  end
  object qRS_Scan: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    DataSource = dlgDS
    SQL.Strings = (
      'SELECT RSS.*'
      'FROM RS_SCAN RSS'
      'WHERE RSS.RSID = :RSID')
    UpdateObject = quRS_Scan
    GeneratorField.Field = 'ASID'
    Left = 235
    Top = 256
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'RSID'
        ParamType = ptUnknown
      end>
    object qRS_ScanRSSPICTURE: TBlobField
      FieldName = 'RSSPICTURE'
      Origin = '"RS_SCAN"."RSSPICTURE"'
      ProviderFlags = [pfInUpdate]
      Size = 8
    end
    object qRS_ScanRSID: TIntegerField
      FieldName = 'RSID'
      Origin = '"RS_SCAN"."RSID"'
      Required = True
    end
  end
  object quRS_Scan: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  RSID,'
      '  RSSPICTURE,'
      '  RSSUSERENTER,'
      '  RSSTIMEENTER,'
      '  RSSUSEREDIT,'
      '  RSSTIMEEDIT'
      'from RS_SCAN '
      'where'
      '  RSID = :RSID')
    ModifySQL.Strings = (
      'update RS_SCAN'
      'set'
      '  RSID = :RSID,'
      '  RSSPICTURE = :RSSPICTURE,'
      '  RSSTIMEEDIT = :RSSTIMEEDIT,'
      '  RSSTIMEENTER = :RSSTIMEENTER,'
      '  RSSUSEREDIT = :RSSUSEREDIT,'
      '  RSSUSERENTER = :RSSUSERENTER'
      'where'
      '  RSID = :OLD_RSID')
    InsertSQL.Strings = (
      'insert into RS_SCAN'
      
        '  (RSID, RSSPICTURE, RSSTIMEEDIT, RSSTIMEENTER, RSSUSEREDIT, RSS' +
        'USERENTER)'
      'values'
      
        '  (:RSID, :RSSPICTURE, :RSSTIMEEDIT, :RSSTIMEENTER, :RSSUSEREDIT' +
        ', :RSSUSERENTER)')
    DeleteSQL.Strings = (
      'delete from RS_SCAN'
      'where'
      '  RSID = :OLD_RSID')
    Left = 267
    Top = 256
  end
  object odScan: TOpenDialog
    Filter = 'PDF|*.pdf'
    InitialDir = 
      '\\servpdc\exchange\'#1054#1073#1097#1080#1081' '#1076#1086#1089#1090#1091#1087'\'#1042#1072#1076#1080#1084'_'#1071#1082#1086#1074#1083#1077#1074#1080#1095'_'#1062#1091#1076#1080#1082#1084#1072#1085'\'#1057#1050#1040#1053#1048#1056#1054 +
      #1042#1040#1053#1048#1045'\'#1044#1077#1090#1089#1082#1080#1081' '#1089#1072#1076' 2010-2011'
    Left = 120
    Top = 200
  end
  object qTarif: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT t.TID, t.TTARIF'
      'FROM DOP_USL_TARIFFS T'
      'WHERE T.SDID = :sdid'
      '    AND :data BETWEEN t.TDATEBEGIN AND t.TDATEEND')
    Left = 289
    Top = 154
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end>
    object qTarifTID: TIntegerField
      FieldName = 'TID'
      Origin = '"DOP_USL_TARIFFS"."TID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qTarifTTARIF: TIBBCDField
      FieldName = 'TTARIF'
      Origin = '"DOP_USL_TARIFFS"."TTARIF"'
      Precision = 18
      Size = 2
    end
  end
end
